package io.ztd.net.androiduitest.scroll;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import io.ztd.net.androiduitest.R;

/**
 * Created by Administrator on 2017/9/22.
 */

public class ScreenSlidePageFragment extends Fragment {
    int position = 0;

    @Override
    public void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        position = (getArguments() != null) ? getArguments().getInt("ztd") : -1;
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        ViewGroup rootView = (ViewGroup) inflater.inflate(
                R.layout.fragment_screen_slide_page, container, false);

        TextView tv = rootView.findViewById(R.id.tv_scolll);
        tv.setText(String.valueOf(position));
        return rootView;
    }

    public static ScreenSlidePageFragment newInstance(int position) {

        // Instantiate a new fragment
        ScreenSlidePageFragment fragment = new ScreenSlidePageFragment();

        // Save the parameters
        Bundle bundle = new Bundle();
        bundle.putInt("ztd", position);
        fragment.setArguments(bundle);
        fragment.setRetainInstance(true);

        return fragment;

    }
}
